(define (sum term a next b)
   (define (iter summand result)
     (if (> summand b)
         result
         (iter (next summand) (+ result (term summand)))))
   (iter a 0))

